module.exports = {
  devServer: {
    proxy: {
      '/api': {
    target: 'http://localhost:8082',
    changeOrigin: true,
        onProxyReq: (proxyReq) => {
          // 确保代理请求保持JSON格式
          if (proxyReq.method === 'POST') {
            proxyReq.setHeader('Content-Type', 'application/json;charset=UTF-8');
            if (proxyReq.body && typeof proxyReq.body === 'object') {
              proxyReq.body = JSON.stringify(proxyReq.body);
            }
          }
        },
      },
      '/spoc': {
        target: 'http://localhost:8082',
        changeOrigin: true,
        pathRewrite: { 
          '^/spoc': '/spoc' // 明确保留一个/spoc前缀
        }
      },
      '/vod': {  // 只代理/vod开头的请求
        target: 'http://localhost:8082',
        changeOrigin: true,
        pathRewrite: {
          '^/vod': '/spoc/vod'  // 将/vod转换为/spoc/vod
        }
      }
    },
  },
};